Skip to main content

All Questions

Tagged with
0votes
1answer
66views

Reducing length with a loop

I have a class which has a series of loops inside of it. Each loop uses a pandas.dataframe to add data to a new list that can be called as an instance attribute. data = [player_stats, ...
Brian's user avatar
1vote
3answers
505views

Ansible - Nested Loop with list of dictionaries when dictionary values are lists

I have a list of dictionaries. Dictionary keys are Cisco Switch names Dictionary values are vlan IDs that are configured on the corresponding switch "switch_vlan_ids": [ { &...
piercjs's user avatar
-2votes
1answer
66views

How to multiply the elements of two lists with each other in python? [duplicate]

You have to create an N-string. An N-string is a string created using two lists. The first list consists of strings. The second list consists of integer values. These two lists are of same length. ...
NAYEEM's user avatar
-1votes
1answer
42views

Printing two related lists

I have an issue that I can't wrap my head around. I have two lists containing related information. The structure of the list is as follows: List_a = [(id_nr, date, event), (...)] List_b = [(id_nr, ...
VirreJoj's user avatar
-1votes
2answers
51views

need to rotate a square matrix by 90degree clockwise. works for 1st loop but gives index out of range the moment it enters next cycle

class Solution: def rotate(self, matrix: List[List[int]]) -> None: for i in range(0, len(matrix)//2): x = i y = len(matrix)-i-1 for j in range(i,len(...
Sankalp Rawat's user avatar
0votes
2answers
189views

How to skip missing data and continue running loop through rest of data

I'm trying to create a function that can pull the first instance of 1 from Expert_Grading_Score column based off of conditions from other columns (subject and treatment). I created two lists with all ...
Shreya's user avatar
-1votes
1answer
53views

Formulating a nested list comprising elements in the same position from another nested list [duplicate]

How can I take a nested list and re-formulate it into a new nested list in which: the first list of the new nested list, B, comprises the first element of all of the lists within the nested list A. ...
bjuksel's user avatar
0votes
3answers
77views

Extract values from list with dicts

I have a list with orders. Each order contains products and their prices. What I want is to write the shortest script possible to count the total number of products sold and the total amount of money ...
Iren E's user avatar
-1votes
1answer
47views

creating diploma using nested lists ( Python )

my collage professor asked to make a diploma that have 2 lists [coruses and students] and nest in it 5 groups in Each group 5 students and fill their names in it Each student have 5 infos(any) all ...
momoshki's user avatar
-1votes
1answer
378views

Python and EarSketch throwing an annoying, recurring error; 'int' does not support indexing on line 33

I am using EarSketch for a assignment at school, a tool that allows you to program music in Python (even if you are not familiar with EarSketch please any input is appreciated, as it seems that my ...
AIDAN GOODRICH's user avatar
-2votes
1answer
36views

Why make another for loop with the variable i and make the range len(new_list) - 1? Where does new_list[i] + 1 and new_list[i + 1} come from?

def any_adjacent_vertebrates(animals, vertebrates): result = False new_list = [] for i in range(len(animals)): for j in range(len(vertebrates)): if animals[i] == ...
Donald's user avatar
1vote
1answer
557views

Harmonic Function (Square Wave Fourier Series) in Python using Nested Loops and Lists

Apologies for the lack of in-line pictures, I am a first time poster. I am trying to plot a square wave via a Fourier Series using nested loops with matplotlib. The square wave is given by the ...
art cut sky's user avatar
1vote
0answers
47views

Why is my python dictionary updating when it is not supposed to (conditions are not being met)?

I am trying to update a dictionary with data I am obtaining from sorting methods. I am obtaining the time it takes for a certain algorithm to finish, I am also counting how many swaps and how many ...
How why e's user avatar
0votes
1answer
30views

How to do a loop over a colnames of data frames stored in a list in r

I'm seeking to conduct a beta regression across columns of multiple data frames stored on a list. The data frames stored in the list are from two data frames, one containing dependent factors and ...
Juan Carlos Rubio Polania's user avatar
0votes
0answers
25views

Convert 2D array into list Python [duplicate]

I have a 2D array and I want to convert into list. My current code can convert into array: z=[[0 for x in range(0,11)] for y in range(0,11)] for y in range (0,11): x=0 z[x][y]=((20-10)/10.0*y+...
Lim Cheng Wei's user avatar

153050per page
close